<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>gh3</title>
    
</head>
<body>
	<ul id="users"></ul>

  <script src="../vendors/jquery-2.1.0.min.js"></script>
  <script src="../vendors/underscore-min.js"></script>
  <script src="../gh3.js"></script>
  <script>

    var GitHubUser = Gh3.User.extend({//instance members
      constructor : function(login) {
        GitHubUser.__super__.constructor.call(this, login);
        GitHubUser.allUsers.push(this);
      }
    },{ //Static members
      allUsers : [],
      each : function (callback) {
        _.each(GitHubUser.allUsers, function (user) {
          callback(user);
        })
      }
    });

    var k33g = new GitHubUser("k33g")
      ,	loicdescotte = new GitHubUser("loicdescotte")
      ,	mklabs = new GitHubUser("mklabs")
      ,	chamerling = new GitHubUser("chamerling")
      ,	usersInfos = $("#users");

    GitHubUser.each(function (user) {
      user.fetch(function (err, resUser) {

        if(err) {
          throw "outch ..."
        }

        usersInfos.append("<li><ul id='"+resUser.login+"'>");

        var tmp_ul = $("#"+resUser.login);
        _.each(_.keys(resUser), function (prop) {
          tmp_ul.append(
            $('<li>').append(prop+" : "+resUser[prop])
          );
        });
      });
    })


  </script>
</body>
</html>
